

function openPopUpItem(baseUrl,itemID,Type)
{
	openWindow(baseUrl+'/customer/edititem/type/'+Type+'/itemID/'+itemID,'Item','500','400','');
	
}
function submitDelItemDetail(theform,item,baseUrl)
{	
		if (confirm('Do you want to delete selected item(s)?') == true){
			theform.action = baseUrl;
			theform.dellist.value = item + ",";
			return theform.submit();
		}
}

function submitDelFormDetail(theform,baseUrl)
{	
	if (makeDelList(theform) > 0) {
		if (confirm('Do you want to delete selected item(s)?') == true){
			theform.action = baseUrl;
			return theform.submit();
		}
	}
}

function submitDelItem(theform,item)
{	
		if (confirm('Do you want to delete selected item(s)?') == true){
			theform.action += '/delete';
			theform.dellist.value = item + ",";
			return theform.submit();
		}
}

function submitDelForm(theform)
{	
	if (makeDelList(theform) > 0) {
		if (confirm('Do you want to delete selected item(s)?') == true){
			theform.action += '/delete';
			return theform.submit();
		}		
	}
}

function submitProductsDisplayedAtHome(theform, actionName){
	theform.action += '/'+actionName;
	return theform.submit();
}

function checkAll(theform)
{	
	if (theform.chkid==null) return;
	var state = theform.chkall.checked;
	var chkitems = theform.chkid.length;
	if (chkitems > 0) {
		for (var i=0; i<chkitems; i++) {
			if (theform.chkid[i].disabled == false)
				theform.chkid[i].checked = state;
		}
	} else {
		if (theform.chkid.disabled == false)
			theform.chkid.checked = state;
	}
}

function checkOneItem(theform) 
{
	var state=true;
	
	var chkitems = theform.chkid.length;
	if (chkitems > 0)
	{
		for (var i=0; i<chkitems; i++)
			if (theform.chkid[i].checked==false){
				state=false;
				break;
				}
	}
	
	theform.chkall.checked = state;
}

function makeDelList(theform)
{			
	var delList="";
	delList += theform.dellist.value;
	var chkitems = theform.chkid.length;
	var count = 0 ;
	if (chkitems >= 2)
	{
		for(var i=0; i<chkitems; i++){
			
			if (theform.chkid[i].checked == true)
			{
				delList += theform.chkid[i].value + ",";
				count++ ;				
			}
		}
		theform.dellist.value = delList;
	}
	else
	{
		if(theform.chkid.checked == true)
		{
			delList	+=	theform.chkid.value+ ",";
			theform.dellist.value = delList;
			return 1;
		}
		return 0;
	}
	return count;
}

function isEmpty(thefield)
{
 	// need to trim the value
	if (thefield.value=='')
		return true;
	return false;
}

function isEmail(email)
{
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   return reg.test(email);
}

function doSubmit(theform)
{	
	return theform.submit();
}


// ---------------------------------------------------------------------------
// Script for view_blockmanager and view_pagemanager
// ---------------------------------------------------------------------------
function refreshListTop(theform, curobject)
{
	//theform.selItemsPerPage.selectedIndex = curobject.selectedIndex;
	theform.selItemsPerPageTop.selectedIndex = curobject.selectedIndex;
	return doSubmit(theform);	
}

function refreshListBot(theform, curobject)
{
	//theform.selItemsPerPage.selectedIndex = curobject.selectedIndex;
	theform.selItemsPerPageBot.selectedIndex = curobject.selectedIndex;
	return doSubmit(theform);	
}

function refreshList(theform, curobject)
{
	//theform.selItemsPerPage.selectedIndex = curobject.selectedIndex;
	//theform.hidSelItemsPerPage.value = theform.selItemsPerPage.value;
	theform.selItemsPerPage.selectedIndex = curobject.selectedIndex;
	return doSubmit(theform);	
}

function showAll(theform, resetlist)
{
	theform.hidPageNO.value = 1;
	if (resetlist!=null)
		for (var i=0; i<resetlist.length; i++)
			resetlist[i].selectedIndex = 0;
	return doSubmit(theform);
}

function showAllTop(theform, resetlist)
{
	theform.hidPageNOTop.value = 1;
	if (resetlist!=null)
		for (var i=0; i<resetlist.length; i++)
			resetlist[i].selectedIndex = 0;
	return doSubmit(theform);
}

function showAllBot(theform, resetlist)
{
	theform.hidPageNOBot.value = 1;
	if (resetlist!=null)
		for (var i=0; i<resetlist.length; i++)
			resetlist[i].selectedIndex = 0;
	return doSubmit(theform);
}

function showPage(theform, page)
{
	theform.hidPageNO.value = page;
	return doSubmit(theform);
}

function showPageTop(theform, page)
{
	theform.hidPageNOTop.value = page;
	return doSubmit(theform);
}

function showPageBot(theform, page)
{
	theform.hidPageNOBot.value = page;
	return doSubmit(theform);
}

function doEdit(theform, theIDfield, cmd, id)
{
	theIDfield.value = id;
	return doSubmit(theform, cmd);
}
function openWindow(filename, winname, width, height, feature) {
 	var features, top, left;
 	var reOpera = /opera/i ;
 	var winnameRequired = ((navigator.appName == "Netscape" && parseInt(navigator.appVersion) == 4) || reOpera.test(navigator.userAgent));

 	left = (window.screen.width - width) / 2;
 	top = (window.screen.height - height) / 2;
 	if(feature == '')
 		features = "width=" + width + ",height=" + height + ",top=" + top + ",left=" + left + ",status=0,location=0";
 	else
 		features = "width=" + width + ",height=" + height + ",top=" + top + ",left=" + left + "," + feature;
	// if(!winnameRequired) winname = "";
 	newwindow = window.open(filename,null,features);
 	newwindow.focus();
}	
function showTimeDate(dayName)
{   	
	monName = new Array ("1","2","3","4","5","6","7","8","9","10","11","12");
	now = new Date;
	document.write( dayName[now.getDay()]+ " " +now.getDate()+ "/ " +monName[now.getMonth()]+ " / " +now.getFullYear() )
}

function hoverBg(self)
{
	$(self).attr("class","tr_bg_hover");
}

function outBg(self)
{
	var id = $(self).attr('id');
	if(id % 2 != 0)
		$(self).removeAttr('class');
	else
		$(self).attr("class",'tr_bg');
}

function changeItemPerPage(self)
{
	$("#hidSelItemsPerPage").val($(self).val());
	$("form").submit();
}

function isEmpty(s)
{   
	return ((s == null) || (s.length == 0))
}

function isWhitespace (s)
{   
	var reWhitespace = /^\s+$/;
	return (isEmpty(s) || reWhitespace.test(s));
}


function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++)
    {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
     {
         IsNumber = false;
     }
    }
   return IsNumber;
}


function haveSpecialChars(s)
{
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?~_";
	for (var i = 0; i < s.length; i++)
	{
		if (iChars.indexOf(s.charAt(i)) != -1)
		{
			return true;
		}
	}
	return false;
}

function haveSpecialCharsForTitle(s)
{
	var iChars = "!@#$%^&*()+=-[]\\\';,.{}|\":<>?~_";
	for (var i = 0; i < s.length; i++)
	{
		if (iChars.indexOf(s.charAt(i)) != -1)
		{
			return true;
		}
	}
	return false;
}

function isInteger(s)
{   
	var reInteger = /^\d+$/;
	return reInteger.test(s);
}

function isFloat(s)
{
	var reFloat = /^((\d+(\.\d*)?)|((\d*\.)?\d+))$/;
	return reFloat.test(s);
}